#include <cstdlib>
#include "DataProcessor.hpp"
#include "RelationManager.hpp"
#include "SourceScan.hpp"
#include "ThreadCounter.hpp"
#include <unistd.h>



int main(int argc, char *argv[])
{
    if (argc < 3)  {
        printf("Usage: %s datafile data_path\n", argv[0]);
        exit(-1);
    }


    ThreadCounter::Init();
    RelationManager relation_manager(argv[2], 16);
    DataProcessor<RelationManager> data_processor(argv[2], relation_manager);

    SourceScan<DataProcessor<RelationManager> > scanner(data_processor);

    scanner.ReadFile(argv[1]);

    data_processor.Done();
    relation_manager.Done();

    do{
        sleep(1);
    }while(ThreadCounter::ThreadNum() > 0);
    return 0;
}
